<template>
  <div class="main-box mocks-comb-main">
    <div class="question-wrap">
      <ul class="item-lists" v-if="partInfo">
        <li class="item-list" v-for="(question, index) in partInfo.question_list">
          <danxuan v-if="question.question_type==1" :index="index + 1" :question="question"></danxuan>
          <tiankong v-if="question.question_type==4" :index="index + 1" :question="question"></tiankong>
          <panduan v-if="question.question_type==6" :index="index + 1" :question="question"></panduan>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
  import Danxuan from '../components/danxuan/index';
  import Tiankong from '../components/tiankong/index';
  import Panduan from '../components/panduan/index';

  export default {
    name: "MocksCombination",
    componentType: 'paperPartQuestion',
    props: {
      partInfo: Object
    },
    components: { Danxuan, Tiankong, Panduan},
    methods: {
      checkUserAnswer () {
        let $children = this.$children;
        if ($children && $children.length) {
          for (let i = 0; i < $children.length; i++) {
            if ($children[i].$options.componentType == 'question') {
              if($children[i].checkUserAnswer()) {
                return true
              }
            }
          }
        }
        return false;
      },
      getPartAnswer () {
        let $children = this.$children;
        let answers = [];
        if ($children && $children.length) {
          $children.forEach($child => {
            answers.push($child.getQuestionAnswer())
          });
        }
        return answers;
      }
    }
  }
</script>
